import { filterFloatNumber } from '@/utils/common'
// 批次列表键值表
export const batchTableProps = [
  { key: '', title: '', minWidth: 90 }
]

// 批次列表状态枚举
export const batchStatusList = [
  { id: 1, name: '待执行' },
  { id: 2, name: '执行中' },
  { id: 3, name: '全部执行成功' },
  { id: 4, name: '部分执行成功' },
  { id: 5, name: '全部执行失败' }
]

// 批次详情列表键值表
export const batchDetailTableProps = [
  { key: '', title: '', minWidth: 90 }
]

// 批次详情执行状态枚举
export const batchDetailStatusList = [
  { id: 1, name: '待执行' },
  { id: 2, name: '执行中' },
  { id: 3, name: '执行成功' },
  { id: 4, name: '执行失败' }
]

// 审批状态
export const approvalStatusList = [
  { id: 1, name: '审批中' },
  { id: 2, name: '审批通过' },
  { id: 3, name: '审批不通过' },
  { id: 4, name: '流程冻结' },
  { id: 5, name: '流程撤销' }
]

/**
 * 批量修改字段表
 * key —— 修改数据v-module的值
 * title —— 修改字段显示标题
 * required —— 是否校验必填
 * maxLength —— 当是输入类型时，最大输入长度
 * input —— @input
 * select —— 使用选择器
 * dataList —— 选择器的数据列表
 * change —— @change
 * show —— v-show
 */
export const batchDetailEditFields = [
  {
    key: 'procCode',
    title: '流程编号',
    required: true,
    maxLength: 20,
    input (fromObj) {
      fromObj.procCode = fromObj.procCode.trim()
    }
  }, {
    key: 'approveResult',
    title: '审批结果',
    select: true,
    required: true,
    dataList: [
      { id: '不通过', name: '不通过' },
      { id: '通过', name: '通过' }
    ]
  }, {
    key: 'remissionMoney',
    title: '减免金额',
    required: true,
    show (item) {
      let { procDefCode, label } = item || {}
      return ['dsxxz', 'dsjmz'].includes(procDefCode) && (procDefCode === 'dsxxz' && label === 11)
    },
    input (fromObj) {
      fromObj.remissionMoney = filterFloatNumber(fromObj.remissionMoney).toFixed(2)
    }
  }
]
